package com.example.forum.utils;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;

/*
    获取cookie中的ticket
 */
public class CookieUtils {
    //获取cookie中的ticket
    public static String getTicket(HttpServletRequest request){
        if(request==null){
            return null;
        }
        Cookie[] cookies = request.getCookies();
        if(cookies==null){
            return null;
        }
        for(Cookie cookie:cookies){
            if(cookie.getName().equals("ticket")){
                return cookie.getValue();
            }
        }
        return null;
    }
}
